<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('退出进度') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true" @submit.native.prevent>
      <el-form-item :label="$t('子基金名称')">
        <el-input v-model="queryParams.dealName" clearable @keyup.enter.native="queryHandle" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
        <el-button
          v-hasPermi="['bf:bfInvestmentProgress:exportReport']"
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="exportHandle"
        >{{ $t("导出") }}</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" tooltip-effect="darkTable" :data="list" border>
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('投资主体名称')" align="center" prop="investName" min-width="200" />
      <el-table-column :label="$t('子基金名称')" align="center" prop="fundName" min-width="200">
        <template slot-scope="scope">
          <router-link
            target="_blank"
            :to="{path:'/deal/home/dealBaseHome', query:{ id:scope.row.dealId }}"
            class="link_a"
          >
            {{ $t(scope.row.fundName) }}
          </router-link>
        </template>
      </el-table-column>
      <el-table-column :label="$t('项目名称')" align="center" prop="dealName" min-width="200" />
      <el-table-column :label="$t('投资时间')" align="center" prop="investTime" min-width="130">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.investTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('持股时间(天)')" align="center" prop="holdTime" min-width="100" />
      <el-table-column :label="$t('持股比例')" align="center" prop="holdScale" min-width="130">
        <template slot-scope="scope">
          {{ moneyFormat(scope.row.holdScale, '') }}%
        </template>
      </el-table-column>
      <el-table-column :label="$t('投资金额') + $t('金额单位')" align="center" prop="investAmount" min-width="130">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.investAmount, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('已退出成本') + $t('金额单位')" align="center" prop="exitCost" min-width="130">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.exitCost, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('退出进度')" align="center" prop="exitProgress" min-width="100">
        <template slot-scope="scope">
          {{ moneyFormat(scope.row.exitProgress, '') }}%
        </template>
      </el-table-column>
      <el-table-column :label="$t('已实现收益') + $t('金额单位')" align="center" prop="realizedProfit" min-width="130">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.realizedProfit, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('IRR')" align="center" prop="irr" min-width="130">
        <template slot-scope="scope">
          {{ formatIrr(scope.row.irr) }}
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { exitList } from '@/api/bf/bfInvestmentProgress/bfInvestmentProgress.js'
export default {
  data() {
    return {
      list: [],
      total: 0,
      loading: false,
      queryParams: {
        dealName: undefined,
        pageNum: 1,
        pageSize: 10
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      exitList(this.queryParams).then(res => {
        this.list = res.rows
        this.total = res.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.dealName = undefined
      this.queryParams.pageNum = 1
      this.queryParams.pageSize = 10
      this.resetForm('queryForm')
      this.queryHandle()
    },
    formatIrr(val) {
      if (val === null || val === undefined || val === '') {
        return '-'
      } else {
        var result = parseFloat(val)
        if (isNaN(result) || result > 100) {
          return result
        } else {
          return result + '%'
        }
      }
    },
    exportHandle() {
      const _this = this
      const queryParams = {
        dealName: this.queryParams.dealName
      }
      this.$confirm(this.$t('是否确认导出?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(function() {
        _this.downLoadExcel('/bf/bfInvestmentProgress/exportReport', queryParams)
      }).catch(function() {
      })
    }
  }
}
</script>

<style scoped>

</style>
